# -*- coding: utf-8 -*-
# @Time    : 2022/5/25 10:11
# @Author  : leijiu
# @Email   : 517711635@qq.com
# @File    : page_goods_brand_list.py
# @Software: PyCharm
"""
商品品牌列表页面
"""
from selenium.webdriver.common.by import By
from time import sleep
from page.page_base import BasePage   #引入基类

class GoodsBrandList(BasePage):

    # 商品品牌定位器
    #商品管理定位器
    ele_goodsadmin_locator = (By.CSS_SELECTOR, "#menu-ul > li.collapse.lis.ico_1")
    #商品品牌定位器
    ele_goodsbrand_locator = (By.LINK_TEXT, "商品品牌")
    #添加品牌定位器
    ele_addgoodsbrand_locator = (By.LINK_TEXT, "添加品牌")
    # 编辑定位器
    ele_alterbrand_locator = (By.CSS_SELECTOR, "#listDiv > table > tbody > tr:nth-child(2) > td:nth-child(6) > a:nth-child(1)")
    # 删除定位器
    ele_deleterbrand_locator = (By.CSS_SELECTOR, "#listDiv > table > tbody > tr:nth-child(2) > td:nth-child(6) > a:nth-child(2)")
    #断言使用
    # 页面切换
    def left_page(self):
        self.driver.switch_to.frame("menu-frame")
        sleep(1)
        # 点击商品管理
    def goods_admin(self):
        self.driver.find_element(*self.ele_goodsadmin_locator).click()
        sleep(1)
    # 点击商品品牌
    def goods_brand(self):
        self.driver.find_element(*self.ele_goodsbrand_locator).click()
        sleep(1)
        # 切换到主页面
    def main_page(self):
        self.driver.switch_to.parent_frame()
        self.driver.switch_to.frame("main-frame")
        sleep(1)
    # 点击添加品牌
    def add_goods_brand(self):
        self.driver.find_element(*self.ele_addgoodsbrand_locator).click()
    # 编辑品牌
    def alter_brand(self):
        self.driver.find_element(*self.ele_alterbrand_locator).click()
    #删除品牌
    def deleter_brand(self):
        self.driver.find_element(*self.ele_deleterbrand_locator).click()
        self.driver.switch_to.alert.accept()
        sleep(1)

